﻿<Window x:Class="IntroductionModule.Views.DownView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:IntroductionModule.ViewModels"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        x:Name="downView"  Title="DownView" WindowStartupLocation="CenterOwner" AllowsTransparency="True" Height="135" Width="310" WindowStyle="None" Background="Transparent">
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Closing">
            <i:InvokeCommandAction Command="{Binding CloseCommand}" CommandParameter="{Binding ElementName=downView}" />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--总颜色样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/Themes/Colors.xaml"/>
                <!--普通按钮样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/ButtonStyle.xaml"/>
                <!--TextBlock样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/TextBlockStyle.xaml"/>
                <!--ScrollViewer样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/ScrollViewerStyle.xaml"/>
                <!--FlipView样式定义-->
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Styles/FlipViewStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Border BorderBrush="{StaticResource border}" BorderThickness="1" CornerRadius="3"  Background="{StaticResource bg_module}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="20"/>
            </Grid.RowDefinitions>
            <!--标题栏-->
            <Grid Grid.Row="0" Background="{StaticResource tilebtn_bg}">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="MouseLeftButtonDown">
                        <i:InvokeCommandAction Command="{Binding DragCommand}" CommandParameter="{Binding ElementName=downView}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="20"/>
                    <ColumnDefinition Width="2"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="33"/>
                    <ColumnDefinition Width="33"/>
                </Grid.ColumnDefinitions>
                <Path Height="12" Width="12" Stretch="Fill" Fill="{StaticResource arrow}" Data="F1 M 42,19.0002L 34,19.0002L 34,43.7502L 24,33.7502L 24,44.2502L 38,58.2502L 52,44.2502L 52,33.7502L 42,43.7502L 42,19.0002 Z"/>
                <TextBlock Grid.Column="2" Text="游戏下载" VerticalAlignment="Center" Foreground="{StaticResource bg_text}"/>
                <Button Grid.Column="3" Height="18" Width="33" Style="{StaticResource SysMinBtn}" VerticalAlignment="Top"
                                        Command="{Binding MinCommand}" 
                                        CommandParameter="{Binding ElementName=downView}"/>
                <Button Grid.Column="4" Height="18" Width="33" Style="{StaticResource SysCloseBtn}" VerticalAlignment="Top"
                                        Command="{Binding CloseCommand}" 
                                        CommandParameter="{Binding ElementName=downView}"/>
            </Grid>
            <ListView Grid.Row="1" ItemsSource="{Binding AllDowns}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                <ListView.View>
                    <GridView AllowsColumnReorder="True">
                        <GridViewColumn Header="游戏" Width="60" DisplayMemberBinding="{Binding GameName}"/>
                        <GridViewColumn Header="大小" Width="50" DisplayMemberBinding="{Binding DownSize}"/>
                        <GridViewColumn Header="进度" Width="100">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <ProgressBar Height="16" Width="88" Value="{Binding DownProgress}"/>
                                        <TextBlock Text="{Binding DownProgress, StringFormat=\{0\}%}" TextAlignment="Center"/>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="速度" Width="50" DisplayMemberBinding="{Binding DownSpeed}"/>
                        <GridViewColumn Header="操作" Width="40">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBlock x:Name="cancel" ToolTip="取消下载任务" Tag="{Binding ID}" Cursor="Hand" Style="{StaticResource cancelTextStyle}" Text="取消"> 
                                            <i:Interaction.Triggers>
                                                        <i:EventTrigger EventName="MouseLeftButtonDown">
                                                            <i:InvokeCommandAction Command="{Binding Path=DataContext.CancelCommand,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Window}}}" 
                                                       CommandParameter="{Binding ElementName=cancel}"/> 
                                                        </i:EventTrigger>
                                                    </i:Interaction.Triggers>
                                        </TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView>
                </ListView.View>
            </ListView>
            <Grid Grid.Row="2" Background="{StaticResource tilebtn_bg}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="2"/>
                </Grid.ColumnDefinitions>
                <TextBlock Grid.Column="0" Text="---最多允许同时添加并下载3个任务." VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="{StaticResource bg_text}"/>
            </Grid>
        </Grid>
    </Border>
</Window>
